<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">

    <style>
        
        
        .box-centre {
           
            padding-left: 20px;
        }
        
        .box-centre input {
            background: url(image/copy.png) no-repeat 4px 1px;
            background-size: 6%;
            padding-left: 28px;
            width: 320px;
            height: 25px;
            border-radius: 5px;
            border: 1px solid #999;
        }
        
        .box-centre .input2 input {
            background: url(image/copy.png) no-repeat 3px 1px;
            background-size: 10%;
            padding-left: 28px;
            width: 203px;
            margin-right: 5px;
        }
        
        .box-centre .input2 button {
            height: 30px;
        }
    </style> 
 
    <title>Document</title>
</head>
<body>
    <div class="box-centre">
        <p> <input type="text" value="" placeholder="您的手机号"></p>
        <p class="input2"><input type="text" value="" placeholder="短信验证码"><button onclick="Testalter()">获取动态验证码</button></p>

    </div>


    <script src="Jquery/jquery.min.js"></script>
 <script>
 

 function Testalter(){
    alert_tips("成功","info");
    
 }
/*
* 说明: 弹窗提示,3秒后自动消失
* 调用: alert_tips('操作成功','success');
* */
function alert_tips(str,status) {
    let info_css = 'display: inline-block;position: fixed;z-index: 888;margin-top:20%;right: 50%;text-align: center;padding: 10px 20px;border-radius: 5px;color: #31708f;background-color: #d9edf7;border-color: #bce8f1';
    let danger_css = 'display: inline-block;position: fixed;z-index: 888;top: 0;right: 30px;text-align: center;padding: 10px 20px;border-radius: 5px;color: #a94442;background-color: #f2dede;border-color: #ebccd1;'
    let success_css = 'display: inline-block;position: fixed;top: 0;right: 30px;text-align: center;padding: 10px 20px;border-radius: 5px;color: #3c763d;background-color: #dff0d8;border-color: #d6e9c6;'
    let warning_css = 'display: inline-block;position: fixed;z-index: 888;top: 0;right: 30px;text-align: center;padding: 10px 20px;border-radius: 5px;color: #8a6d3b;background-color: #fcf8e3;border-color: #faebcc;'
    let add_alert = '';
    if(status === 'success'){
        add_alert = '<span id="alert_test" style="'+success_css+'">'+str+'</span>';
    }else if(status === 'info'){
        add_alert = '<span id="alert_test" style="'+info_css+'">'+str+'</span>';
    }else if(status === 'danger'){
        add_alert = '<span id="alert_test" style="'+danger_css+'">'+str+'</span>';
    }else if(status === 'warning'){
        add_alert = '<span id="alert_test" style="'+warning_css+'">'+str+'</span>';
    }
    $('body').append(add_alert);
    //transition: all 3s 2s linear;
    $('span#alert_test').css({"top":"30px","transition":"3s"});
    setTimeout(() => {
        // console.log('sleep 1.8s.');
        let index = 10;
        let interval = setInterval(function () {
            if(index === -60){ //设3秒时间段
                clearInterval(interval);
                $('#alert_test').remove(); //显示完后删除节点
            }
            $('span#alert_test').css({"opacity":(index/10)});
            // console.log('===>',index);
            index--;
        },30)
    }, 1000); //延时1.8秒
}


 </script>
</body>
</html>